package com.authine.cloudpivot.ext.applicationservice;

import com.alibaba.cola.dto.SingleResponse;
import com.authine.cloudpivot.ext.applicationservice.base.ApplicationBaseService;
import com.authine.cloudpivot.ext.constants.ModelConst;
import com.authine.cloudpivot.ext.dto.transfer.MemberPurchaseOrderGoodsDto;
import com.authine.cloudpivot.ext.utils.BoServiceUtils;
import com.authine.cloudpivot.ext.utils.StringUtils;
import com.authine.mvp.app.launcher.dto.bo.response.BO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import lombok.extern.slf4j.Slf4j;

import javax.ws.rs.POST;
import javax.ws.rs.Path;

import java.util.HashMap;
import java.util.Map;

import static com.authine.hermes.app.launcher.service.ApplicationServiceFoundation.CUSTOM_SERVICE;

/**
 * @Author: liwei
 * @DateTime: 2021/10/14
 * @Description:  采购订单商品 列表相关处理
 */
@Path("TransferPurchaseOrderItemService")
@Slf4j
public class TransferPurchaseOrderItemService extends ApplicationBaseService {


    /**
     * 转采管理-采购订单商品-更新预计到货时间
     * arrival_time
     * @param dto
     * @return
     */
    @Path("updatePurchaseArrivalTime")
    @POST
    @Operation(summary = "转采管理-采购订单商品-更新预计到货时间", tags = CUSTOM_SERVICE, description = "id、arrival_time必填")
    public SingleResponse<BO> updatePurchaseArrivalTime(@Parameter MemberPurchaseOrderGoodsDto dto) {

        if (StringUtils.isBlank(dto.getId())) {
            return SingleResponse.buildFailure("-1", "会员采购订单ID必填");
        }

        Map<String, Object> param = new HashMap<>();
        param.put("id", dto.getId());
        param.put("arrival_time", dto.getArrival_time());

        return BoServiceUtils.updateMainBo(ModelConst.T_MEMBER_PURCHASE_ORDER_GOODS, param);
    }



}
